	/**
	 * 检验申请单js
	 */

	var yangbenselect;
	var tableList1; //第一个的数据
	var tableList2; //第二个的数据
	var tableList3; //第三个的数据
//	var table1List;
	function L1()
	{
		var url1=rootUrl+"/doctoradviceeditor/yangben" ;
		var params1={} ;
		$.get(url1,params1,function(data)
				{
				//样本列表
				yangbenList = data.list;
				yangbenselect = "<select>";
				for(var j = 0; j<yangbenList.length; j++)
				{
					var option = "<option value='"+yangbenList[j]['abb01']+"' >"+yangbenList[j]['abb02']+"</option>";
					yangbenselect += option;
				}
				yangbenselect += "</select>";
				////////////////////////////////////页签1
				
				var url =rootUrl+"/doctoradviceeditor/requestnote";
				var params = {};
				params.lACF01 = 1;
				params.lBCE01 = bce01;
				params.currPage = 1;
				params.pageSize = 100;
				$.ajax({
					url : url,
					type : "post",
					async : true, 
					data : params,
					dataType : 'json',
					success : function(data) {
						$("#L11_left").empty();
					    var rows  = data.rows;//bdo03
					    tableList1 = data.list;
						for(var j = 0;j<rows.length;j++)
						{
							var li = $("<li onclick=\"L11Table('"+rows[j]+"',this)\">");
							var span1=$("<span>").attr({class:"glyphicon glyphicon-chevron-right"});
							var span = $("<span>").text(rows[j]);
							li.append(span1);
							li.append(span);
							//ul.append(li);
							$("#L11_left").append(li);
						}
						$("#L11_left").find("li").eq(0).trigger('click');
					}
				});
				//查询组合及自定义项目
				////////////////////////////////////页签二
				/*var url1 =rootUrl+"/doctoradviceeditor/rapeuticschedule";;
				var params1 = {};
				params1.lACF01 = 1;
				params1.lBCE01 = bce01;
				$.ajax({
					url : url1,
					type : "post",
					async : true, 
					data : params1,
					dataType : 'json',
					success : function(data) {
						$("#L21_left").empty();
						var bdoList = data.list;
						tableList2 = data.rows;
						for(var i = 0;i<bdoList.length;i++)
						{
							var li = $("<li onclick=\"L21Table("+bdoList[i]["bdo01"]+",this)\">").attr({id:bdoList[i]["bdo01"]});
							var span1=$("<span>").attr({class:"glyphicon glyphicon-chevron-right"});
							var span = $("<span>").text(bdoList[i]["bdo03"]);
							li.append(span1);
							li.append(span);
							$("#L21_left").append(li);
						}
						$("#L21_left").find("li").eq(0).trigger('click');
					}
				});*/
				///////////////////////////////页签三
				var url2 =rootUrl+"/doctoradviceeditor/requestnotedetailitem";;
				var params2 = {};
				params2.lACF01 = 1;
				params2.lBCE01 = bce01;
				params2.currPage = 1;
				params2.pageSize = 100;
				$.ajax({
					url : url2,
					type : "post",
					async : true, 
					data : params2,
					dataType : 'json',
					success : function(data) {
						$("#L31_left").empty();
						tableList3 = data.list;
						var row = data.rows;
						for (var k=0;k<row.length;k++){
							var li = $("<li onclick=\"L31Table('"+row[k]+"',this)\">");
							var span1=$("<span>").attr({class:"glyphicon glyphicon-chevron-right"});
							var span = $("<span>").text(row[k]);
							li.append(span1);
							li.append(span);
							$("#L31_left").append(li);
						}
						$("#L31_left").find("li").eq(0).trigger('click');
					}
				});
				
				});
		
	}
	
	//页签1中tree和table交互事件
	function L11Table(id,that)
	{
		$(that).addClass("selected").siblings().removeClass("selected")
		var resultList = [];
		for(var i = 0;i<tableList1.length;i++)
		{
			if(id == tableList1[i]["bdo03"])
			{
				resultList.push(tableList1[i]);
			}
		}
		$("#L11_Table").empty();
		configTr("L11_Table",resultList);
	}
	//页签2中tree和table交互事件
	function L21Table(id,that)
	{
		$(that).addClass("selected").siblings().removeClass("selected")
		var resultList = [];
		for(var i = 0;i<tableList2.length;i++)
		{
			if(id == tableList2[i]["bdo01"])
			{
				resultList.push(tableList2[i]);
			}
		}
		
		$("#L21_Table").empty();
		configTr("L21_Table",resultList);
	}
	
	//页签3中tree和table交互事件
	function L31Table(id,that)
	{
		$(that).addClass("selected").siblings().removeClass("selected")
		var resultList = [];
		for(var i = 0;i<tableList3.length;i++)
		{
			if(id == tableList3[i]["bdo03"])
			{
				resultList.push(tableList3[i]);
			}
		}
		$("#L31_Table").empty();
		configTr("L31_Table",resultList);
	}
	
	//根据list构造table
	function configTr(tableId,list)
	{
		
		for(var i = 0;i<list.length;i++)
		{
			var bda01 = list[i]["bda01"];
			var bbx01 = list[i]["bbx01"];
			var bbx04 = list[i]["bbx04"];
			var bdg02 = list[i]["bdg02"];
			var bbx06 = list[i]["bbx06"];
			var mycolor = "black";
			if(tableId=="L11_Table")
			{
				var bbx12 = list[i]["bbx12"];
				switch (bbx12)
				{
					case 1 :
						mycolor = "blue";
						break;
				}
			}
			else if (tableId=="L21_Table")
			{
				var bbx15 = list[i]["bbx15"];
				switch (bbx15)
				{
					case 0 :
						mycolor = "red";
						break;
					case 1 :
						mycolor = "blue";
						break;
					case 2 :
						mycolor = "green";
						break;
				}
			}
			else if(tableId=="L31_Table")
			{
				var bbx12 = list[i]["bbx12"];
				switch (bbx12)
				{
					case 1 :
						mycolor = "red";
						break;
				}
			} 
			var arr = {};
			arr.bda01 = bda01;
			arr.bbx01 = bbx01;
			arr.bbx04 = bbx04;
			arr.bdg02 = bdg02;
			arr.bbx06 = bbx06;
			var label = $("<label class='label-normal' data-pinyin ='"+(list[i]["bbx05"]).toPinYin()+"'></label>");
			var checkbox = $("<input type='checkbox' class='magic-checkbox' data-info='"+JSON.stringify(arr)+"'/>");
			var span = $("<span></span>");
			span.append(list[i]["bbx05"]);
			var td = $("<td></td>");
			var div = $("<div style='position:relative;width:100%;height:100%;color:"+mycolor+"'></div>");
			td.append(div);
			div.append(label);
			label.append(checkbox);
			label.append(span);
			var temp_9 = $(yangbenselect);
			if (bbx06)
			{
				//			$(yangbenselect).find("option[text='"+bbx06+"']").attr("selected","selected");
				temp_9.val(bbx06);
			}
			div.append(temp_9);
			//排列<td>,按照每行3列排
			if(i%3==0)
			{
				var tr = $("<tr></tr>");
			}
			tr.append(td);
			$("#"+tableId).append(tr);
		}
		$("#"+tableId).find("select").select2({});
//		iChenckInit($("#"+tableId).find('input[type="checkbox"]'));
	}
	
//页面搜索功能；
function checkListSearch(){
	debugger;
	var curLi = $("#jianyan_xiangmu").find(".active a").attr("href");
	var tableid;
	if(curLi == "#zhzdy"){
		tableid = "L11_Table";
	}else if(curLi == "#xmlb"){
		tableid = "L31_Table";
	}
	$("#"+tableid).find("td").removeClass("this-chose");
	var text = $("#check_list_search").val().trim();
	var reg= /^[A-Za-z]+$/; //判断是字母
	if(text){
		
		if (reg.test(text)){
			text = text.toUpperCase();
			var allL = $("#"+tableid).find("td").find("label");
			allL.each(function(i,e){
				if($(e).attr("data-pinyin").toUpperCase().indexOf(text)>=0){
					$(e).parents("td").addClass("this-chose");
				}
			})
		}else{
			$("#"+tableid).find("td").find("label").filter(":contains('"+text+"')").parents("td").addClass("this-chose");
		}
	}
}	

function checkListInput(){
	$("#check_list_search").on("keydown",function(){
		 var e = event || window.event || arguments.callee.caller.arguments[0];
			if (e && e.keyCode == 13){
				checkListSearch();
				
			}
	})
}
